package com.bw.module_parking.viewModel

import androidx.lifecycle.MutableLiveData
import com.bw.lib_common.coroutine.CoroutineHelper
import com.bw.lib_common.vm.BaseViewModel2
import com.bw.module_parking.entity.ParkingEntity
import com.bw.module_parking.repo.ParkingRepo
import kotlinx.coroutines.launch

class ParkingViewModel : BaseViewModel2<ParkingRepo>() {
    val getParkingSuccess by lazy { MutableLiveData<List<ParkingEntity>>() }

    fun getParking(areaId:Int){
        CoroutineHelper.mViewModelScope.launch(CoroutineHelper.mDispatcher) {
            val result = mRepository.getParking(areaId)
            if(result.code==200){
                getParkingSuccess.postValue(result.data)
            }else{
                mErrorLiveData.postValue("获取数据异常！！")
            }
        }
    }


    override fun createRepository(): ParkingRepo {
        return ParkingRepo()
    }


}